class Solution(object):
    def rotate(self, nums, k):
        k=k%len(nums)
        self.reverse(nums,0,len(nums)-1)
        self.reverse(nums,0,k-1)
        self.reverse(nums,k,len(nums)-1)
        return nums
    def reverse(self,nums,i,j):
        while i<j:
            nums[i],nums[j]=nums[j],nums[i]
            i+=1
            j-=1
x=Solution()
print(x.rotate([1,2,3,4,5,6,7],3))